﻿tinymce.init({
    language: "zh",
    mode: "textareas",
    //    elements: "txtAnswer",
    width: "600px",
    height: "320px",
    document_base_url: "/handball/",
    relative_urls: true,
    theme: "advanced",
    plugins: "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",
    theme_advanced_buttons1: "formatselect,fontselect,fontsizeselect,forecolor,backcolor,separator,table,bold,italic,underline,strikethrough,separator,bullist,numlist,separator, justifyleft, justifycenter, justifyright,justifyleft,justifycenter,justifyright,outdent,indent,removeformat,separator,link,unlink,image,quote,code,fullscreen,insertCode",
    theme_advanced_buttons2: "",
    theme_advanced_buttons3: "",
    theme_advanced_resizing: true,
    theme_advanced_resize_horizontal: false,
    theme_advanced_toolbar_location: "top",
    theme_advanced_toolbar_align: "left",
    theme_advanced_statusbar_location: "bottom",
    theme_advanced_fonts: "宋体=宋体;黑体=黑体;仿宋=仿宋;楷体=楷体;隶书=隶书;幼圆=幼圆;Arial=arial,helvetica,sans-serif;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats",
    convert_fonts_to_spans: true,
    remove_trailing_nbsp: true,
    convert_newlines_to_brs: false,
    force_br_newlines: false,
    force_p_newlines: false,
    remove_linebreaks: false,
    relative_urls: false,
    extended_valid_elements: "pre[name|class]",
    //content_css: "/Style/css/mce.css", 
    //cleanup_callback:"myCustomCleanup",
    handle_event_callback: "MCECheckIndent",
    cleanup: true
});


function MCECheckIndent(e) {

    if (e.type == 'keydown' && e.keyCode == 9) {
        tinyMCE.execCommand('mceInsertContent', false, '　　');
        return false;
    }
    else if (e.type == 'keydown' && e.ctrlKey && e.keyCode == 13) {
        doAnswer();
        return false;
    }
}

function InsertToEditor(content) {
    tinyMCE.execCommand('mceInsertContent', false, content);
}
